package tools;

/** 二叉树节点 */
public class Node<T> {

    private T data;

    private Node<T> leftNode;

    private Node<T> rightNode;

    public Node(T key) {
        data = key;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Node<T> getLeftNode() {
        return leftNode;
    }

    public void setLeftNode(Node<T> leftNode) {
        this.leftNode = leftNode;
    }

    public Node<T> getRightNode() {
        return rightNode;
    }

    public void setRightNode(Node<T> rightNode) {
        this.rightNode = rightNode;
    }

    public Node<T> getRightmostNode() {
        Node<T> current = this;
        while (current.getRightNode() != null) {
            current = current.getRightNode();
        }
        return current;
    }
}
